/*******************************************************************************
 * The MOSES project, model based software engineering of networked embedded systems.
 * 
 * Copyright (C) 2010-2013, University of Applied Sciences Wildau,
 * Telematics Research Group, http://www.tm.th-wildau.de/research-group
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 * 
 * Contributors:
 *     University of Applied Sciences Wildau - initial API and implementation
 * 
 * If you are interested in a commercial license please contact us via 
 * e-mail: ralf.vandenhouten@th-wildau.de.
 ******************************************************************************/
package de.thwildau.tm.moses.avro.ui.syntaxcoloring;

import static org.eclipse.swt.SWT.BOLD;
import static org.eclipse.swt.SWT.NORMAL;

import org.eclipse.swt.graphics.RGB;
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration;
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor;
import org.eclipse.xtext.ui.editor.utils.TextStyle;

/**
 * This class define a configuration for the coloring of the language.
 * 
 * @author Thomas Kistel
 * @version $Revision: 1$
 * @see http://www.eclipse.org/Xtext/documentation/2_1_0/195-highlighting.php
 */
public class AvroHighlightingConfiguration implements IHighlightingConfiguration {

    public static final String ANNOTATION = "Annotations";
    public static final String COMMENT = "Comments";
    public static final String KEYWORD = "Keywords";
    public static final String STRING = "Strings";
    
    public static final String VALUE = "Values";
    public static final String ARGUMENTS = "Arguments";
    public static final String PROTOCOL = "Protocols";
    public static final String DEFTYPES = "Types already defined";
    public static final String ENUMFIELDS = "Enum fields";


    public void configure(IHighlightingConfigurationAcceptor acceptor) {
        setTextStyle(ANNOTATION, acceptor, 100, 100, 100, NORMAL);
        setTextStyle(COMMENT, acceptor, 63, 127, 95, NORMAL);
        setTextStyle(KEYWORD, acceptor, 127, 0, 85, BOLD);
        setTextStyle(STRING, acceptor, 42, 0, 255, NORMAL);
        setTextStyle(VALUE, acceptor, 0, 0, 0, NORMAL);
        setTextStyle(ARGUMENTS, acceptor, 0, 0, 0, NORMAL);
        setTextStyle(DEFTYPES, acceptor, 0, 0, 0, NORMAL);
        setTextStyle(ENUMFIELDS, acceptor, 0, 0, 0, NORMAL);
    }

    public void setTextStyle(String component, IHighlightingConfigurationAcceptor acceptor, int r, int g, int b,
            int style) {
        TextStyle textStyle = new TextStyle();
        textStyle.setColor(new RGB(r, g, b));
        textStyle.setStyle(style);
        acceptor.acceptDefaultHighlighting(component, component, textStyle);
    }
}
